﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title>MLSMooc医学检验学慕课</title>
    <style>
        .text {
            border-bottom: #666 1px solid;
            border-left-width: 0px;
            border-right-width: 0px;
            border-top-width: 0px;
        }

        /*  display: flex; justify-content: center; align-items: center; */
    </style>
    <!-- CSS -->
    <link href="NewFolder1/css/main.css" rel="stylesheet" />

    <link href="../layui-v2.6.8/layui/css/layui.css" rel="stylesheet" />
    <script src="NewFolder1/js/jquery.min.js"></script>

    <script src="../layui-v2.6.8/layui/layui.js"></script>
    <script src="NewFolder1/js/jzkszx.js"></script>

</head>
<body>



    <!--<div class="mainbox box-center" style="width:700px;height:320px;">-->
    <!--题-->
    <div class="col-r-01 box-shadow-ie-r mt10 right" style="width: 670px; height: 500px;" id="divc">
        <!--<b class="b1"></b><b class="b2"></b><b class="b3 "></b>-->
        <!--<div id="Content1"></div>-->
        <div id="Content" class=" bc bc-h04  box-shadow p10" style="border: none;padding-left:25px;">

        </div>
        <!--<form class="layui-form" action="">
            <div class="layui-form-item">

                    <button id="Course-Insert" class="layui-btn layui-btn-normal layui-btn-save" lay-submit="" type="submit"  lay-filter="Course-Insert">提交</button>

            </div>

        </form>-->

    </div>
    <!--</div>-->



</body>

</html>
<script>

    $(function () {

        var res = window.location.search;
        var resdata = res.split(",")
        if (res == "") {

        } else {
            if (resdata.length <= 1) {
                prourlid = resdata[0].split("=")[1];
                GetExam(prourlid);
            }

        }


    })
    var flag = 0;
    function GetExam(id) {

        var obj = {};
      /*  obj.id = id*/
        obj.Cid = id
        $.ajax({
            /* url: '../../Course/GetCourse1',*/
            url: '../../Exam/GetCourse_ExamList',
            type: 'get',
            data: obj,
            dataType: 'json',
            contentType: 'application/json',
            async: false,
            success: function (data) {
                console.log(data)
                var resultData = data;
                var strA = "1";
                var strB = "2";
                var strC = "3";
                var strD = "4";
                var strE = "5";
                var Str = "";
              
                if (resultData != undefined && resultData.length != 0) {

                /*    if (resultData[0].t1 != 0) {*/
                        // Str += '<b class="b1 bb1"></b><b class="b2 bb2"></b><b class="b3 bb2"></b><div class="bc bb2" ><div class="bt bb3 bc-h03"><span><a><img class="png" src="images/jian.png" /></a></span>第一部分：  单选题（每题1.00分,共' + (resultData[0].t1 * 1) + '分）</div></div ><b class="b3 bb2"></b><b class="b2 bb2"></b><b class="b1 bb1"></b>';
                        for (var i = 0; i < Object.keys(resultData).length; i++) {
                            if (resultData[i].TopicType == 1 && resultData.length > 0) {
                                var imgval = "";
                                var ss = resultData[i].Img.length;
                                if (ss>45) {
                                    flag = 1;
                                    imgval = "<p><img src='" + resultData[i].Img + "' width='290px' height='163px'/></p>";
                                }
                                //Str += '<div class="m-choicebox" style="margin-bottom:10px;"><p>' + resultData[i].Topic + '(　)。</p><p><img alt="" src="' + resultData[i].Img + '" /></p></h4><ul class="single"><li class="question-option-list"><span>A．</span><div class="option-content">' + resultData[i].OptionA + '</div></li><li class="question-option-list"><span>B．</span><div class="option-content">' + resultData[i].OptionB + '</div></li><li class="question-option-list"><span>C．</span><div class="option-content">' + resultData[i].OptionC + '</div></li><li class="question-option-list"><span>D．</span><div class="option-content">' + resultData[i].OptionD + '</div></li><li class="question-option-list"><span>E．</span><div class="option-content">' + resultData[i].OptionE + '<br/><br /></div></li ></ul><div class="m-checkBox single"><a  class="question-btn  ' + resultData[i].Id + '" id="lblA' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strA + ')"><label for="rdA' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionA + '"  name="rd' + resultData[i].Id + '"  id="rdA' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strA + ')" />&nbsp;&nbsp;A</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblB' + resultData[i].Id + '"><label for="rdB' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionB + '"  name="rd' + resultData[i].Id + '"  id="rdB' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strB + ')" />&nbsp;&nbsp;B</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblC' + resultData[i].Id + '"><label for="rdC' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionC + '"  name="rd' + resultData[i].Id + '"  id="rdC' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strC + ')" />&nbsp;&nbsp;C</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblD' + resultData[i].Id + '"><label for="rdD' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionD + '"  name="rd' + resultData[i].Id + '"  id="rdD' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strD + ')" />&nbsp;&nbsp;D</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblE' + resultData[i].Id + '"><label for="rdE' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionE + '"  name="rd' + resultData[i].Id + '"  id="rdE' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strE + ')" />&nbsp;&nbsp;E</label></a></div></div>';
                                Str += '<div class="m-choicebox" style="margin-bottom:10px;"><p>' + resultData[i].Topic + '(　)。</p>'+imgval+'</h4><ul class="single"><li class="question-option-list"><span>A．</span><div class="option-content">' + resultData[i].OptionA + '</div></li><li class="question-option-list"><span>B．</span><div class="option-content">' + resultData[i].OptionB + '</div></li><li class="question-option-list"><span>C．</span><div class="option-content">' + resultData[i].OptionC + '</div></li><li class="question-option-list"><span>D．</span><div class="option-content">' + resultData[i].OptionD + '</div></li><li class="question-option-list"><span>E．</span><div class="option-content">' + resultData[i].OptionE + '<br/><br /></div></li ></ul><div class="m-checkBox single"><a  class="question-btn  ' + resultData[i].Id + '" id="lblA' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strA + ')"><label for="rdA' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionA + '"  name="rd' + resultData[i].Id + '"  id="rdA' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strA + ')" />&nbsp;&nbsp;A</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblB' + resultData[i].Id + '"><label for="rdB' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionB + '"  name="rd' + resultData[i].Id + '"  id="rdB' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strB + ')" />&nbsp;&nbsp;B</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblC' + resultData[i].Id + '"><label for="rdC' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionC + '"  name="rd' + resultData[i].Id + '"  id="rdC' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strC + ')" />&nbsp;&nbsp;C</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblD' + resultData[i].Id + '"><label for="rdD' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionD + '"  name="rd' + resultData[i].Id + '"  id="rdD' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strD + ')" />&nbsp;&nbsp;D</label></a><a  class="question-btn  ' + resultData[i].Id + '" id="lblE' + resultData[i].Id + '"><label for="rdE' + resultData[i].Id + '"><input type="radio" value="' + resultData[i].OptionE + '"  name="rd' + resultData[i].Id + '"  id="rdE' + resultData[i].Id + '" onclick="checkanswer(' + resultData[i].Id + ',' + resultData[i].TopicType + ',' + strE + ')" />&nbsp;&nbsp;E</label></a></div></div>';

                                break;
                            }
                        //}
                    }
                    Str += '<br/><br/><div style="text-align:center;margin-top:10px;"><form class="layui-form"><div class="layui-form-item"><button id="Course-Insert" class="layui-btn layui-btn-normal layui-btn-save" type="button"  lay-filter="Course-Insert">提交</button></div></from></div>';
                    $("#Content").append(Str)

                } else {
                    Str += '<br/><br/><div id="kdiv" style="text-align:center;width: 670px; height:495px;line-height:180px;"><p>本课程暂无习题</p><form class="layui-form"><div class="layui-form-item"><button id="Course-qued" class="layui-btn layui-btn-normal layui-btn-save" type="button"  lay-filter="Course-qued">确定</button></div></from></div>';
                    $("#Content").append(Str)
                    //alert("本课程暂无习题")290px*163px


                }
                if (flag==0) {
                    var bg = $("#divc");
                 
                    bg.css("height","325px");
                 
                    var kg = $("#kdiv");
                    kg.css("height", "325px");
             
                }
            }
        })
    }


    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form

        //form.on('submit(Course-Insert)', function (data) {
        //    alert(111);
        //    UpExam();
        //    return false;
        //});
        $("#Course-Insert").click(function () {
            UpExamssss();
            getclose();


        });
        $("#Course-qued").click(function () {

            getclose();

        });

    });
    function getclose() {
        var dd = parent.elevideo;//layui调用父页面的元素；

        dd.play();
        parent.aa = 2;//layui改变父页面的aa值；
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        // parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
        parent.layer.close(index); //再执行关闭
    }

    function UpExamssss() {
        var Infoarray = new Array();
        var obj = {};
        obj.id = prourlid;
        $.ajax({
            /* url: '../../Course/GetCourse1',*/
            url: '../../Course/GetTanKCourse1',
            type: 'get',
            data: obj,
            dataType: 'json',
            contentType: 'application/json',
            async: false,
            success: function (data) {
                var resultData = data;
                if (resultData != undefined) {
                    for (var i = 0; i < Object.keys(resultData).length; i++) {
                        var Exam_Info = {};
                        Exam_Info.Eid = resultData[i].Id;
                        Exam_Info.AdminId = sessionStorage.getItem("AdminId");
                        Exam_Info.CourseId = resultData[i].CourseId;
                        if (resultData[i].TopicType == 4) {
                            var optionstr = resultData[i].OptionTrue.split("____")
                            var selectoptin = "";
                            for (var l = 0; l < optionstr.length - 1; l++) {
                                if ($("#Option" + resultData[i].Id + "_" + (l + 1) + "").val() != undefined) {
                                    selectoptin += $("#Option" + resultData[i].Id + "_" + (l + 1) + "").val() + "、";
                                } else {
                                    selectoptin += "空、"
                                }

                            }
                            Exam_Info.SelectOption = selectoptin;
                        }
                        else {
                            var arr = "";
                            if ($('input[name="rd' + resultData[i].Id + '"]:checked').val() == null) {
                                Exam_Info.SelectOption = null;
                            } else {
                                $('input[name="rd' + resultData[i].Id + '"]:checked').each(function (i) {
                                    if (arr == "") {
                                        arr = $(this).val();
                                    } else {
                                        arr += "," + $(this).val() + "";
                                    }

                                });
                                Exam_Info.SelectOption = arr;
                            }
                        }


                        Infoarray.push(Exam_Info)
                        break;
                    }
                    console.log(Infoarray)
                    $.ajax({
                        /* url: '../../Exam/VideoExamAnswer',*/
                        url: '../../Exam/VideoTanKExamAnswer',
                        type: 'post',
                        data: JSON.stringify(Infoarray),
                        dataType: 'json',
                        contentType: 'application/json',
                        async: false,
                        success: function (data) {
                           

                            alert(data);


                        }
                    })

                }
            }
        })




    }


</script>
